<template>
    <div>
        <el-container class="home-con">
            <!-- 主框架的头部 -->
            <el-header class="home-head">
                <span style="margin-left: 10px;">奥凯航空后勤资产管理系统</span>
                <div>
                    <el-badge style="display: flex; align-items: center; margin-right: 7px;">
                    </el-badge>
                    <el-dropdown style="display: flex; align-items: center;">
                        <span class="home-user" style="align-items: center;">用户姓名
                            <i><img style="width: 40px; height: 40px; margin-right: 5px; margin-left: 5px; border-radius: 1px"
                                    src="../assets/logo.png"></i>
                        </span>
                        <el-dropdown-menu slot="dropdown">
                            <el-dropdown-item>个人中心</el-dropdown-item>
                            <el-dropdown-item>设置</el-dropdown-item>
                            <el-dropdown-item @click.native="logout()">注销</el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown>
                </div>
            </el-header>
            <el-container>
                <!-- 导航 -->
                <el-aside style="width: 195px; backgruond-color: #ececec;">
                    <div style="display: flex; justify-content: flex-start; width: 180px; text-align: left;">
                        <el-menu style="backgruond-color: #ececec; width: 180px;">
                            <el-submenu index="1-1">
                                <template slot="title"><i class="el-icon-s-unfold"></i>基础信息管理</template>
                                <el-menu-item index="1-1-1" @click="goto('/sysdict')">
                                    <i class="el-icon-notebook-1"></i>
                                    <span>数据字典管理</span>
                                </el-menu-item>
                                <el-menu-item index="1-1-2" @click="goto('/catalog')">
                                    <i class="el-icon-notebook-2"></i>
                                    <span>资产分类管理</span>
                                </el-menu-item>
                                <el-menu-item index="1-1-3" @click="goto('/employee')">
                                    <i class="el-icon-suitcase"></i>
                                    <span>公司职员管理</span>
                                </el-menu-item>
                                <el-menu-item index="1-1-4" @click="goto('/sysuser')">
                                    <i class="el-icon-user"></i>
                                    <span>系统用户管理</span>
                                </el-menu-item>
                            </el-submenu>
                            <el-submenu index="2-1">
                                <template slot="title"><i class="el-icon-s-finance"></i>资产信息管理</template>
                                <el-menu-item index="2-1-1" @click="goto('/normal')">
                                    <i class="el-icon-paperclip"></i>
                                    <span>普通资产信息</span>
                                </el-menu-item>
                                <el-menu-item index="2-1-2" @click="goto('/finance')">
                                    <i class="el-icon-coin"></i>
                                    <span>金融资产信息</span>
                                </el-menu-item>
                                <el-menu-item index="2-1-3" @click="goto('/car')">
                                    <i class="el-icon-truck"></i>
                                    <span>车辆资产信息</span>
                                </el-menu-item>
                                <el-menu-item index="2-1-4" @click="goto('/permanent')">
                                    <i class="el-icon-s-home"></i>
                                    <span>不 动 产信息</span>
                                </el-menu-item>
                            </el-submenu>
                            <el-submenu index="3-1">
                                <template slot="title"><i class="el-icon-sort"></i>资产流转管理</template>
                                <el-menu-item index="3-1-1" @click="goto('/normalTrans')">
                                    <i class="el-icon-sort"></i>
                                    <span>普通资产流转</span>
                                </el-menu-item>
                                <el-menu-item index="3-1-2" @click="goto('/financeTrans')">
                                    <i class="el-icon-sort"></i>
                                    <span>金融资产流转</span>
                                </el-menu-item>
                                <el-menu-item index="3-1-3" @click="goto('/carTrans')">
                                    <i class="el-icon-sort"></i>
                                    <span>车辆资产流转</span>
                                </el-menu-item>
                                <el-menu-item index="3-1-4" @click="goto('/permanentTrans')">
                                    <i class="el-icon-sort"></i>
                                    <span>不 动 产流转</span>
                                </el-menu-item>
                            </el-submenu>
                        </el-menu>
                    </div>
                </el-aside>
                <!-- 工作区域 -->
                <el-main>
                    <el-breadcrumb separator-class="el-icon-arrow-right">
                        <el-breadcrumb-item>首页</el-breadcrumb-item>
                        <el-breadcrumb-item v-text="this.$router.currentRoute.name"></el-breadcrumb-item>
                    </el-breadcrumb>
                    <div class="block" v-if="show">
                        <el-carousel :height="bannerHeight + 'px'">
                            <el-carousel-item v-for="item in imgs" :key="item.url">
                                <img :src="item.url" class="bannerimg" />
                            </el-carousel-item>
                        </el-carousel>
                    </div>

                    <keep-alive>
                        <router-view v-if="this.$route.meta.keepAlive"></router-view>
                    </keep-alive>
                    <router-view v-if!="this.$route.meta.keepAlive"></router-view>
                </el-main>
            </el-container>
        </el-container>
    </div>
</template>

<script>
export default {
    name: "home",
    data() {
        return {
            router: [],
            show: true,
            bannerHeight: 200,
            imgs: [
                { url: require("../assets/img1.png") },
                { url: require("../assets/img2.png") },
                { url: require("../assets/img3.png") },
                { url: require("../assets/img4.png") }
            ],
        }
    },
    mounted() {
        this.setSize();
        window.addEventListener('resize', () => {
            this.setSize();
        }, false);
    },
    methods: {
        goto(url) {
            console.log(url);
            this.show = false;
            this.$router.replace(url);
        },
        logout() {
            console.log("注销");
            this.$router.push('/');
        },
        setSize() {
            this.bannerHeight = document.body.clientWidth / 3
        }
    }
}
</script>

<style scoped>
.block {
    margin-top: 20px;
}

.bannerimg {
    width: 100%;
    height: inherit;
}

.el-carousel__item h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    line-height: 150px;
    margin: 0;
}

.el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n+1) {
    background-color: #d3dce6;
}

.home-con {
    height: 100px;
    position: absolute;
    top: 0px;
    left: 0px;
    width: 100%;
}

.home-head {
    background-color: #20a0ff;
    color: #333;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: content-box;
    padding: 0px;
}

.home-user {
    width: 180px;
    min-width: 175px;
}
</style>>